package leetcode;

public class Test4 {
    public static void main(String[] args) {
        int[] nums1 = new int[]{0, 0, 1, 1, 1, 1, 2, 3, 3}; // 输入数组
        int[] nums2 = new int[]{1, 1, 1, 2, 2, 3}; // 输入数组
        int k = removeDuplicates(nums1);
        System.out.println(k);
    }

    public static int removeDuplicates(int[] nums) {
        if (nums.length < 2) {
            return nums.length;
        }
        int lower = 2, fast = 2;
        while (fast < nums.length) {
            if (nums[lower - 2] != nums[fast]) {
                nums[lower] = nums[fast];
                lower++;
            }
            fast++;
        }
        return lower;
    }
}
